home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
c
/
uw_1.exe
/
UW_TUT10.C
< prev
next >
Wrap
Text File
|
1992-11-02
|
22KB
|
531 lines
/****************************************************************************/
/* UW_TUT10.C */
/* */
/* NOTE: THIS FILE IS PUBLIC DOMAIN AND MAY BE MODIFIED AND USED AT WILL */
/* */
/* Now we add the finishing touch - context sensitive help using the */
/* UltraWin/InTUItion help engine, which we call by using the "C" system */
/* call. The help engine is created with InTUItion and requires the */
/* InTUItion libraries to make this a linkable part of your program. */
/* However, as you will see, we can call the stand-alone help program to */
/* take full advantage of this hypertext help system! */
/* */
/* Dr. Boyd Gafford */
/* Kevin Huck */
/* EnQue Software */
/* 09/16/92 */
/****************************************************************************/
#include <stdio.h>
#include <fcntl.h>
#include <io.h>
#ifndef __TURBOC__
#include <sys\types.h>
#endif
#include <sys\stat.h>
#include <time.h>
#include <ctype.h>
#include "uw.h" /* include the necessary headers */
#define MAX_CUST 50
typedef struct cust
{
int status;
int cust_no;
char business[34];
char name[34];
char addr[34];
char city[34];
char state[4];
char zip[10];
char phone[16];
char fax[16];
char date[10];
char memo[34];
char unused[26]; /* round out to 256 bytes */
} CUST;
/*----------------------- global window variables --------------------------*/
WINDOW Desk_wn, Window1;
CUST Customers[MAX_CUST];
char Fname[33];
MENU Top_menu, *Top_mnp = &Top_menu;
MENU Files_menu, Edit_menu, Print_menu;
MENU *Drop_mnps[3];
PRINT Print;
/*-------------------------------- prototypes ------------------------------*/
int disp_time(void);
void disp_cust(CUST *cp, WINDOW *wnp);
int file_load(CUST *customers);
int file_save(CUST *customers);
int get_fname(char *fname);
void print_cust(CUST *cp, PRINT *p);
void do_external_help( char *cmd );
/*********/
/* ~main */
/* ********************************************************************/
/* Demonstrate data entry capability... */
/****************************************************************************/
int main()
{
int i, ret_val, cust = 0, end_flag = 0, print_stat = 0;
char *search, buff[81];
WINDOW *wnp;
CUST *cp;
uchar back_att = (LIGHTGRAY << 4) | BLACK,
bdr_att = (LIGHTGRAY << 4) | BLACK,
csr_att = (CYAN << 4) | YELLOW,
first_att = (LIGHTGRAY << 4) | RED;
wnp = &Window1; /* set local window pointer */
init_video(80, 25); /* init video for 80 x 25 screen */
init_clock(0x3333); /* init clock irq at 91 tics/sec */
init_mouse(); /* init mouse if available */
wn_create(0, 0, V_cols-1, V_rows-1, NO_BDR, WN_NORMAL, &Desk_wn);
link_window(&Desk_wn);
/*------------------------ create the menu system ------------------------*/
Drop_mnps[0] = &Files_menu;
Drop_mnps[1] = &Edit_menu;
Drop_mnps[2] = &Print_menu;
menu_create(0, 0, V_cols - 1, 0, M_HORIZONTAL,
back_att, bdr_att, csr_att, first_att,
NO_BDR, WN_NORMAL, Top_mnp);
item_add( " Files ", 1, 3, &Top_menu );
item_add( " Edit ", 2, 3, &Top_menu );
item_add( " Print ", 8, 3, &Top_menu );
menu_create(0, 1, 14, 5, M_VERTICAL,
back_att, bdr_att, csr_att, first_att,
SGL_BDR, WN_NORMAL, Drop_mnps[0]);
item_add( " Load File", 4, 1, &Files_menu );
item_add( " Save File", 5, 1, &Files_menu );
item_add( " Quit ", 3, 3, &Files_menu );
menu_create(11, 1, 32, 4, M_VERTICAL,
back_att, bdr_att, csr_att, first_att,
SGL_BDR, WN_NORMAL, Drop_mnps[1]);
item_add( " Clear Current", 6, 7, &Edit_menu );
item_add( " Clear All ", 7, 7, &Edit_menu );
menu_create(22, 1, 43, 4, M_VERTICAL,
back_att, bdr_att, csr_att, first_att,
SGL_BDR, WN_NORMAL, Drop_mnps[2]);
item_add( " Print Current", 9, 7, &Print_menu );
item_add( " Print All ", 10, 7, &Print_menu );
set_idle_func(disp_time); /* set background clock function */
wn_create(5, 5, 75, 20, SLD_BDR, WN_POPUP, wnp);
wn_color(YELLOW, BLUE, wnp); /* change the window colors */
wn_bdr_color(WHITE, BLUE, wnp); /* change the border's colors */
link_window(wnp);
/*-------------- initialize first customer as EnQue Software --------------*/
cp = &Customers[0];
strcpy(cp->business, "EnQue Software");
strcpy(cp->name, "Kevin Huck & Boyd Gafford");
strcpy(cp->addr, "Rt. 1 Box 116C");
strcpy(cp->city, "Pleasant Hill");
strcpy(cp->state, "MO");
strcpy(cp->zip, "64080");
strcpy(cp->phone, "(816)987-2515");
strcpy(cp->fax, "(816)987-2515");
strcpy(cp->date, "09/11/92");
strcpy(cp->memo, "BBS 816-358-8990");
/*------------------------ initialize the printer ------------------------*/
if( init_printer("LPT1", NULL, 2048L, 2048L, &Print) )
print_stat = 1;
Top_mnp->csr_pos = M_MAX_ENTRIES; /* set to prevent menu from hiliting */
menu_set(Top_mnp); /* on entry, since menu is not active until */
Top_mnp->csr_pos = 0; /* Alt-F, Alt-E, or Alt-P is hit */
wn_color(LIGHTGRAY, RED, &Desk_wn);
wn_plst(CENTERED, 3, "Use cursor keypad to select customer", &Desk_wn);
wn_plst(CENTERED, 4, "or click on cursor buttons at bottom of screen", &Desk_wn);
wn_plst(CENTERED, 21, "<Up> <Dn> <PgUp> <PgDn> <Home> <End>", &Desk_wn);
wn_plst(CENTERED, 22, "<<< Press Alt-H or click on desired item for help >>>", &Desk_wn);
wn_color(YELLOW, RED, &Desk_wn);
while(!end_flag)
{
cp = &Customers[cust];
mv_cs(1,1, wnp);
wn_printf(wnp, "Customer:%3d", cust+1);
disp_cust(cp, wnp);
m_show();
wait_event();
m_hide();
search = NULL;
if( Event.is_mouse ) /* process mouse action */
{
if( range(0,Event.m_x,11) && (Event.m_y == 0) )
Event.key = KEY_ALT_F, search = "///File";
else if( range(11,Event.m_x,22) && (Event.m_y == 0) )
Event.key = KEY_ALT_E, search = "///Edit";
else if( range(22,Event.m_x,33) && (Event.m_y == 0) )
Event.key = KEY_ALT_P, search = "///Print";
else if( range( 7,Event.m_x,47) && (Event.m_y == 9) )
Event.key = 'B', search = "///Business";
else if( range( 7,Event.m_x,47) && (Event.m_y == 10) )
Event.key = 'N', search = "///Name";
else if( range( 7,Event.m_x,47) && (Event.m_y == 11) )
Event.key = 'A', search = "///Address";
else if( range( 7,Event.m_x,47) && (Event.m_y == 12) )
Event.key = 'C', search = "///City";
else if( range(50,Event.m_x,59) && (Event.m_y == 12) )
Event.key = 'S', search = "///State";
else if( range(61,Event.m_x,71) && (Event.m_y == 12) )
Event.key = 'Z', search = "///Zip";
else if( range( 7,Event.m_x,47) && (Event.m_y == 13) )
Event.key = 'P', search = "///Phone";
else if( range( 7,Event.m_x,47) && (Event.m_y == 14) )
Event.key = 'F', search = "///Fax";
else if( range( 7,Event.m_x,47) && (Event.m_y == 15) )
Event.key = 'D', search = "///Date";
else if( range( 7,Event.m_x,47) && (Event.m_y == 16) )
Event.key = 'M', search = "///Memo";
else if( range( 21,Event.m_x,24) && (Event.m_y == 21) )
Event.k